//
//  EditViewController.m
//  MyChat
//
//  Created by Ansen on 15-2-3.
//  Copyright (c) 2015年 Ansen. All rights reserved.
//

#import "EditViewController.h"
#import "NSString+Helper.h"

@interface EditViewController ()<UITextFieldDelegate>

@property (weak, nonatomic) IBOutlet UITextField *contentText;

@end

@implementation EditViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    // 1. 设置标题
    self.title = _contentTitle;
    
    // 2. 设置文本内容
    _contentText.text = _contentLabel.text;
    
    // 3. 设置输入框的焦点
    [_contentText becomeFirstResponder];
    
}

#pragma mark - 文本框代理
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
    [self save:nil];
    
    return YES;
}

#pragma mark - 保存操作
- (IBAction)save:(id)sender {
    
    if ([_delegate respondsToSelector:@selector(editVCardViewControllerDidFinished)]) {
        _contentLabel.text = [_contentText.text trimString];
        [_delegate editVCardViewControllerDidFinished];
        [self.navigationController popViewControllerAnimated:YES];
    }
 
}


@end
